package com.gpframework.module.module.domain.req;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.gpframework.common.utils.StringUtils;
import com.gpframework.module.base.domain.req.BaseReq;
import com.gpframework.module.module.domain.BrandStore;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.ToString;
import lombok.experimental.Accessors;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

/**
 * @ClassName BrandStoreReq
 * @Author gpframework
 * @Date 2022-03-25
 * @Version 1.0.0
 * @Description 列表查询信息体
 */
@Data
@ToString
@EqualsAndHashCode
@NoArgsConstructor
@Accessors(chain = true)
public class BrandStoreReq extends BaseReq {
    private static final long serialVersionUID = 1L;

    @ApiModelProperty("ID")
    private Long storeId;
    @ApiModelProperty("门店编码")
    private String storeNo;
    @ApiModelProperty("品牌id")
    private Long brandId;
    @ApiModelProperty("品牌名称")
    private String brandName;
    @ApiModelProperty("订单id（最新）")
    private Long orderId;
    @ApiModelProperty("系统用户id")
    private Long brandUserId;
    @ApiModelProperty("系统账号")
    private String userName;
    @ApiModelProperty("平台销售员id")
    private Long salesId;
    @ApiModelProperty("平台销售名称")
    private String salesName;
    @ApiModelProperty("推荐人")
    private String referrerUserName;
    @ApiModelProperty("门店名称")
    private String storeName;
    @ApiModelProperty("门店网址")
    private String storeWebsite;
    @ApiModelProperty("门店介绍")
    private String storeIntroduce;
    @ApiModelProperty("门店logo")
    private String storeLogo;
    @ApiModelProperty("门店地址")
    private String storeAddress;
    @ApiModelProperty("门店经度")
    private String storeLongitude;
    @ApiModelProperty("门店纬度")
    private String storeLatitude;

    @ApiModelProperty("用户经度")
    private String userLongitude;
    @ApiModelProperty("用户纬度")
    private String userLatitude;

    @ApiModelProperty("门店联系电话")
    private String storeMobile;
    @ApiModelProperty("门店邮箱")
    private String storeEmail;
    @ApiModelProperty("门店小程序二维码")
    private String storeQrcodeApp;
    @ApiModelProperty("门店支付二维码")
    private String storeQrcodePay;
    @ApiModelProperty("营业执照")
    private String licenseImage;
    @ApiModelProperty("法人")
    private String leaderName;
    @ApiModelProperty("联系方式（法人）")
    private String leaderMobile;
    @ApiModelProperty("是否试用过;0 否。1 是。")
    private String isTryout;
    @ApiModelProperty("试用多久（小时）。默认1天。")
    private Integer tryoutHour;
    @ApiModelProperty("短信总数量")
    private Integer smsTotalNum;
    @ApiModelProperty("短信发送数量")
    private Integer smsSendNum;
    @ApiModelProperty("短信剩余数量")
    private Integer smsNum;
    @ApiModelProperty("合同剩余数量")
    private Integer contractNum;
    @ApiModelProperty("有效开始时间")
    private Date effTimeStart;
    @ApiModelProperty("有效结束时间")
    private Date effTimeEnd;
    @ApiModelProperty("使用期限(天)")
    private Integer useTime;
    @ApiModelProperty("门店状态;-10 过期。0 未开业。10 营业中。20 暂停使用。")
    private String storeStatus;
    @ApiModelProperty("显示的门店状态")
    private String showStatus;
    @ApiModelProperty("审核状态;1审核中、2审核通过、3不通过、4禁用")
    private String auditStatus;
    @ApiModelProperty("排序")
    private Integer sort;
    @ApiModelProperty("备注")
    private String remarks;
    @ApiModelProperty("创建者")
    private String createBy;
    @ApiModelProperty("创建时间")
    private Date createTime;
    @ApiModelProperty("更新者")
    private String updateBy;
    @ApiModelProperty("更新时间")
    private Date updateTime;
    @ApiModelProperty("删除标记;0未删除。1已删除。")
    private Long delStatus;
    @ApiModelProperty("付费金额")
    private BigDecimal payPrice;

    @ApiModelProperty("选择门店id")
    private Long chooseStoreId;

    @ApiModelProperty("移动端用户id")
    private Long userId;

    @ApiModelProperty("准备过期天数")
    private Integer preparationExpirePromptDay;

    @ApiModelProperty("门店ids")
    private List<Long> storeIds;

    /**
     * 小程序跳转地址
     */
    @ApiModelProperty("小程序跳转地址")
    private String page;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty("搜索开始时间")
    private Date searchStartTime;
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty("搜索结束时间")
    private Date searchEndTime;
    /**
     * 区域ids
     */
    @ApiModelProperty("区域ids")
    private String areaIds;

    /**
     * @Description 生成查询wrapper
     * @Author greatplan@qq.com
     * @Date 2020-11-04 16:04
     * @Param [lqw]
     * @Param [isVO] 是否vo查询体，true的话走的是mapper.xml里面的查询语句，不过查询语法还是mybatis-plus，主要用于某些关联查询出一些非数据表字段
     * @Return void
     */
    public void generatorQuery(QueryWrapper<BrandStore> lqw, boolean isVo) {
        String alias = "";
        if (isVo) {
            alias = "gp.";
            lqw.eq(alias + "del_status", 0);
        }
        if (this.getStoreId() != null) {
            lqw.eq(alias + "store_id", this.getStoreId());
        }
        if (this.getBrandId() != null) {
            lqw.eq(alias + "brand_id", this.getBrandId());
        }
        if (StringUtils.isNotBlank(this.getBrandName())) {
            lqw.eq(alias + "brand_name", this.getBrandName());
        }
        if (this.getOrderId() != null) {
            lqw.eq(alias + "order_id", this.getOrderId());
        }
        if (this.getBrandUserId() != null) {
            lqw.eq(alias + "brand_user_id", this.getBrandUserId());
        }
        if (this.getSalesId() != null) {
            lqw.like(alias + "sales_id", this.getSalesId());
        }
        if (StringUtils.isNotBlank(this.getSalesName())) {
            lqw.like(alias + "sales_name", this.getSalesName());
        }
        if (StringUtils.isNotBlank(this.getUserName())) {
            lqw.like(alias + "user_name", this.getUserName());
        }
        if (StringUtils.isNotBlank(this.getStoreName())) {
            lqw.like(alias + "store_name", this.getStoreName());
        }
        if (StringUtils.isNotBlank(this.getStoreWebsite())) {
            lqw.eq(alias + "store_website", this.getStoreWebsite());
        }
        if (StringUtils.isNotBlank(this.getStoreIntroduce())) {
            lqw.eq(alias + "store_introduce", this.getStoreIntroduce());
        }
        if (StringUtils.isNotBlank(this.getStoreLogo())) {
            lqw.eq(alias + "store_logo", this.getStoreLogo());
        }
        if (StringUtils.isNotBlank(this.getStoreAddress())) {
            lqw.eq(alias + "store_address", this.getStoreAddress());
        }
        if (StringUtils.isNotBlank(this.getStoreLongitude())) {
            lqw.eq(alias + "store_longitude", this.getStoreLongitude());
        }
        if (StringUtils.isNotBlank(this.getStoreLatitude())) {
            lqw.eq(alias + "store_latitude", this.getStoreLatitude());
        }
        if (StringUtils.isNotBlank(this.getStoreMobile())) {
            lqw.eq(alias + "store_mobile", this.getStoreMobile());
        }
        if (StringUtils.isNotBlank(this.getStoreEmail())) {
            lqw.eq(alias + "store_email", this.getStoreEmail());
        }
        if (StringUtils.isNotBlank(this.getStoreQrcodeApp())) {
            lqw.eq(alias + "store_qrcode_app", this.getStoreQrcodeApp());
        }
        if (StringUtils.isNotBlank(this.getStoreQrcodePay())) {
            lqw.eq(alias + "store_qrcode_pay", this.getStoreQrcodePay());
        }
        if (StringUtils.isNotBlank(this.getLicenseImage())) {
            lqw.eq(alias + "license_image", this.getLicenseImage());
        }
        if (StringUtils.isNotBlank(this.getLeaderName())) {
            lqw.like(alias + "leader_name", this.getLeaderName());
        }
        if (StringUtils.isNotBlank(this.getLeaderMobile())) {
            lqw.eq(alias + "leader_mobile", this.getLeaderMobile());
        }
        if (StringUtils.isNotBlank(this.getIsTryout())) {
            lqw.eq(alias + "is_tryout", this.getIsTryout());
        }
        if (this.getTryoutHour() != null) {
            lqw.eq(alias + "tryout_hour", this.getTryoutHour());
        }
        if (this.getEffTimeStart() != null) {
            lqw.eq(alias + "eff_time_start", this.getEffTimeStart());
        }
        if (this.getEffTimeEnd() != null) {
            lqw.eq(alias + "eff_time_end", this.getEffTimeEnd());
        }
        if (StringUtils.isNotBlank(this.getStoreStatus())) {
            lqw.eq(alias + "store_status", this.getStoreStatus());
        }
        if (StringUtils.isNotBlank(this.getShowStatus())) {
            lqw.eq(alias + "show_status", this.getShowStatus());
        }
        if (StringUtils.isNotBlank(this.getAuditStatus())) {
            lqw.eq(alias + "audit_status", this.getAuditStatus());
        }
        if (this.getSort() != null) {
            lqw.eq(alias + "sort", this.getSort());
        }
        if (StringUtils.isNotBlank(this.getRemarks())) {
            lqw.eq(alias + "remarks", this.getRemarks());
        }
        if (StringUtils.isNotBlank(this.getCreateBy())) {
            lqw.eq(alias + "create_by", this.getCreateBy());
        }
        if (this.getCreateTime() != null) {
            lqw.eq(alias + "create_time", this.getCreateTime());
        }
        if (StringUtils.isNotBlank(this.getUpdateBy())) {
            lqw.eq(alias + "update_by", this.getUpdateBy());
        }
        if (this.getUpdateTime() != null) {
            lqw.eq(alias + "update_time", this.getUpdateTime());
        }
        if (this.getDelStatus() != null) {
            lqw.eq(alias + "del_status", this.getDelStatus());
        }
        if (StringUtils.isNotBlank(this.getAreaIds())) {
            lqw.like(alias + "area_ids", this.getAreaIds());
        }
        lqw.orderByDesc(alias + "create_time");
        lqw.orderByAsc(alias + "sort");
        lqw.groupBy(alias + "store_id");
    }
}
